Skip to content

0.9.2: safer answer cache, versioned benchmarks, local API proxy, ultra through the kit - #1

Merged
chteau merged 41 commits into
masterfrom
0.9.2
Oct 11, 2026
Merged

chteau merged 41 commits into
masterfrom
0.9.2

Conversation

@chteau

@chteau chteau commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

0.9.2 consolidates correctness after an external review, and adds a local API proxy that cuts tokens further.

Correctness

  • Answer cache replays only information questions, into the state they were asked in (repo, branch, commit, working tree, manifests); !nocache bypass.
  • Bench reports and charts name the TokenForge version, build and Claude Code version; mixed versions are refused.
  • Memory reloads on resume and compaction; subagent work is summarized into snapshots; handoffs are kept until used.
  • Workers run sensitive checks in a temporary git worktree.
  • Bash router: differential tests against the commands as typed, with fixes for quoting, expansions, pipe stages and glob order.

Token savings

  • tforge proxy / tforge claude: a local proxy (127.0.0.1 only, optional, on by default) that logs request sizes and compresses tool results on first send, and prunes stale context when the reads it saves outweigh the cache rewrite.
  • Repo map at session start; tview output budget.
  • Lean ultra: a policy line sends edits to tkit edit (tmap 0.5.1 accepts unclosed new/append bodies).
  • Codex and opencode plugins over the same hooks.

Benchmark

6 tasks, lean ultra + proxy, 9 runs per task against 4 native runs (Claude Opus 5.5), objective grading (rubrics and hidden tests):

task tokens cost
cross-module-debug −66.8% −55.8%
rust-debug −64.3% −49.9%
banking-transfers −58.8% −49.1%
architecture −55.2% −44.9%
go-feature −51.4% −32.1%
pr-review −45.7% −40.8%
median −57.0% −47.0%

Quality unchanged (equal or better on 4 tasks, −1.3 and −0.3 points on the other two).

Test plan

  • npm test: 156 pass
  • cargo test --release -- --test-threads=1 (tmap): 157 pass
  • CI green
  • After merge: tag tmap-v0.5.1 so release binaries exist for the new version

chteau and others added 30 commits October 10, 2026 05:16
…extForge audit

- Add formal cache invalidation framework (lib/cache-invalidation.mjs)
- Add semantic deduplication with FNV-1a + SimHash (lib/semantic-dedup.mjs, hooks/semantic-dedup.mjs)
- Add AST-aware compression with vault retrieval (lib/compression.mjs, hooks/compression.mjs)
- Add enhanced hook pipeline with session cache, stall detection, concept cache (hooks/enhanced-interceptor.mjs)
- Add context packs system for task-specific context (lib/context-packs.mjs)
- Add vector memory with TF-IDF + RP-tree ANN (lib/vector-memory.mjs)
- Add usage receipts system (lib/receipts.mjs)
- Add tmap client interface (lib/tmap-client.mjs)
- Fix regex fallback compression: skipTrivialCheck, error handlers, function body compression
- Fix compressCode skipTrivialCheck logic for tool results
- Fix compressCode check order (token threshold before line count)
- Fix regex fallback compression: function bodies, error handlers, small files
- Fix compressToolResults minLines default
- Fix pruneStaleRetrieves most recent retrieve logic

Test results: 196 passing, 6 failing (4 compression edge cases, 2 receipt heisenbugs)
…ong changelog

The three PreToolUse/PostToolUse hooks ran on every tool call with no effect
(one crashed on import; two read a payload.messages field Claude Code never
sends). The libraries were reachable only from three undocumented tforge
commands, two of which crashed. Restores the tree of d5ea765.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erify validation

Tasks marked "sensitive" (or every task with plan-level "isolateChecks") run their verify command in a
detached worktree of HEAD brought to the checkout's state, removed afterwards even on timeout. Refused
outside git. verify rejects NUL and stray newlines; destructive patterns are warned about.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ion; refuse mixed versions without --mixed-versions; tforge version

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…doffs until used

- SessionStart also runs on resume (only what changed while away) and compact (own checkpoint).
- Snapshots fold subagent transcripts: type, task, files edited, commands, report.
- Automatic handoffs are archived once a session given them has worked, or after 14 days.
- New settings: subagentSkip, stateFiles, reloadOn, leanKeep.
- Agents with their own definition get no scope/ask/planning rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h 0.9.2 status

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…were asked in

Never replays a request to run, test, build, verify or deploy, a security
question or one about the current state (English and French). Validity now
includes the repo (top level and remotes), HEAD and branch, the working tree
by content, dependency manifests, the terse level and the model when known.
!nocache as a prompt's first or last word bypasses it. Adversarial tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…urns, not instructions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eanKeep, handoff archive, subagent summaries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nv-prefix quoting, lost expansions, dropped pipe stages, cat glob order; check logs keep FAILED lines after warnings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and usage and compresses tool results on first send

Whole-file Reads fold long bodies (line numbers kept, Read offset/limit markers),
Bash output is cleaned and capped with the full text saved, large JSON is crushed.
Compressed results are memoized by tool_use_id and original hash so later
requests resend identical bytes and the prompt cache holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unters, per-file counts on capped search results; tforge run --proxy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…olding after an Edit miss; Windows: spawn claude.cmd through cmd.exe with escaped args, proxy tests in Windows CI; offline proxy replay estimate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
…ead of refusing it

Claude Code shows any PreToolUse deny as "hook error", which users on Windows
took for a crash. A whole Read of a tool-results/*.txt over 8k chars is now
allowed with offset/limit set to its last ~8k chars (at least 20 lines) and a
note on the line range; repeating the whole Read still loads it all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
… spill reads

A whole-file Read of dependency source, a lockfile or a generated file reads
its first 200 lines with a note; a lone `cat` of dependency source goes
through tview. Narrowed Reads carry no permission decision (Claude Code
applies updatedInput and keeps its own permission check), so nothing gets
auto-approved. Interactive ssh and installers waiting for an answer stay
refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
.codex-plugin/plugin.json points Codex at the shared hooks/hooks.json. Under Codex
(PLUGIN_ROOT or turn_id), MCP distill replaces the result with decision:block and the
polling-wait cap is skipped, since Codex takes updatedInput only with allow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
…or startup

lib/opencode.mjs runs kit-router and session-start with Claude-shaped input and maps
their answers onto tool.execute.before/after and experimental.chat.system.transform.
`tforge opencode install|remove [--project]` writes a one-line re-export. Under Codex
or opencode, session start leaves Claude Code's settings alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
…Y_OPENAI_UPSTREAM)

Current-turn function_call_output items are compressed like Bash and tool
results (JSON-wrapped shell output keeps its wrapper), memoized by call_id;
usage comes from response.completed. Logs keep sizes only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
opencode 2 refused the plugin ("must export a default definition with an
id and an effect or setup function"). setup(ctx) now registers
tool execute.before/after (the tool is "shell") and session context
(system parts { type: 'text' }); the v1 TokenForge factory stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
…shells

Claude Code adds a plugin's bin/ to PATH, opencode does not: the ssh
refusal pointed at `tkit ssh` and got "command not found", and router
rewrites to tkit would fail the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
chteau and others added 9 commits October 11, 2026 00:28
process.env.PATH set by the plugin does not reach the commands: opencode
starts zsh, which rebuilds PATH from the user's rc files, and `tkit --help`
still failed with "command not found". A command that runs tkit, tmap,
tread or tview (from the model or a router rewrite) now gets
`export PATH='<bin>':"$PATH"; ` in front. The input is changed in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
Neither host puts the plugin's bin/ on PATH, so router rewrites to tkit
failed with "command not found" under Codex. withKitPath moves to
hookutil; kit-router prefixes its rewrites with
`export PATH='<bin>':"$PATH";` outside Claude Code, and session-start
tells non-Claude agents the same prefix for their own kit commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
- tview stays under Claude Code's Bash output limit (BASH_MAX_OUTPUT_LENGTH - 4000,
  TFORGE_VIEW_MAX): the largest code files become outlines, documents print whole.
  Persisted outputs (2KB preview) were behind most re-reads in the benchmark.
- Router: cat with one brace group goes through tview; cat piped into grep/sed
  is no longer rewritten (they would search folded text).
- Proxy: TFORGE_PROXY_TTL=5m or header x-tokenforge-cache-ttl: 5m (not forwarded)
  asks for the 5-minute cache. Off by default.
- Policy: "Batch reads (<25k chars)".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
…tart

- lib/prune.mjs: stale tool results (re-read or rewritten files, identical
  commands, superseded test runs, written bodies read back) and thinking from
  earlier turns become stubs, in deterministic batches (TFORGE_PROXY_PRUNE
  tokens|cost|off, TFORGE_PROXY_PRUNE_MIN). Report shows pruning and
  context_management.
- lib/proxy-setup.mjs: first session turns the proxy on in the Claude Code
  settings once it answers; tforge proxy on|off; hooks restart it; never
  next to the user's own base URL or a cloud provider; TFORGE_PROXY=0.
- Session start loads a capped tmap repo map (TFORGE_MAP=0 off).
- Policy: independent tool calls in one message. /tokenforge:proxy skill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
Once the model has moved on (3 calls, or an earlier turn), Write content,
heredoc bodies (also after a prefix command), Edit strings and the heredoc
bodies of successful scripts (python3 - <<'EOF') become stubs; the command
keeps its shape. Earlier-turn reads of files changed since go too.
TFORGE_PROXY_PRUNE_WRITES=0 disables the age rule. The proxy no longer
cleans or caps cat/sed -n/head/tview output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
Logs, per request, the characters and blocks of thinking from earlier turns
(what pruning drops) and from the current turn; sizes only. The report shows
whether dropping earlier thinking saves anything with the current model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
Current Claude Code appends a `system` message after the tool results, so the
last message was never the one holding them and nothing was compressed. The
newest results are now taken from the last user message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
Benchmarks showed tokens-mode pruning breaking a warm cache to drop a few
thousand tokens (one batch rewrote 51k tokens to drop 5.5k). Headless runs
have no human pauses, so the 1-hour cache only makes their writes dearer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
…d bodies; ultra kit policy

- Proxy pruning, cost mode: the batch is the run of pending items that saves
  the most cache reads net of the rewrite (one old stale item used to block
  every batch). Written bodies and ran scripts go after 2 model calls.
- tkit edit (tmap 0.5.1): `@@ path new|append` without <<< >>> takes the raw
  text up to the next @@ or EOF; an unclosed <<< in those modes ends there.
- Lean ultra: a policy line sends edits to tkit edit, with each block marker
  spelled out, and new files to `cat >`.
- Roadmap: smaller code reads (cat / sed -n), measured by replay first.

Benchmark, 6 tasks, ultra + proxy, 9 runs per task against 4 native runs:
median -57.0% tokens, -47.0% cost, quality unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
@chteau chteau added the enhancement New feature or request label Oct 11, 2026
@chteau chteau self-assigned this Oct 11, 2026
chteau and others added 2 commits October 11, 2026 22:20
…ows hosts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
…mp stays within its budget

Long temp paths on macOS pushed a 4-file dump 564 chars over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qx4xQdY1hCQkSjJ5iuZFFT
@chteau
chteau merged commit 225c3d2 into master Oct 11, 2026
20 checks passed
@chteau
chteau deleted the 0.9.2 branch October 11, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant